<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>员工列表</title>
<script src="${pageContext.request.contextPath }/js/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
	$(function(){
		$(".delete").click(function() {
			if(confirm("你是否确认删除该条数据")){
				$("#f1").attr("action",this.href)
				$("#f1").submit();
				//屏蔽超链接的默认动作
				return false;
			}
		})
	});
</script>
<style>
	h1{
		text-align: center;
	}
	#emp{
		text-align: center;
		margin: 0 auto;
		border: 1px solid blue; 
		border-collapse: collapse;
		width: 600px;/*表格宽度*/
	}
	#emp td,#emp th{
		border: 1px solid blue; 
		height: 35px;
	}
	#emp tr:nth-child(odd) {/*斑马线效果 偶数even*/
		background-color: yellow;	
	}
	#p1{
		text-align: right;
		width: 600px;
		margin: auto;
	}
</style>
</head>
<body>
	<h1>员工列表</h1>
	<p id="p1"><a href="${pageContext.request.contextPath }/emp/view">新增</a></p>
	<table id="emp">
		<tr>
			<th>员工编号</th>
			<th>姓名</th>
			<th>工资</th>
			<th>部门</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${empList}" var="emp">
			<tr>
				<td>${emp.empId}</td>
				<td>${emp.name}</td>
				<td>${emp.sal}</td>
				<td>${emp.deptId}</td>
				<td>
				<a href="${pageContext.request.contextPath}/emp/${emp.empId}">修改</a>
				<a class="delete" href="${pageContext.request.contextPath}/emp/${emp.empId}">删除</a>
				</td>
			</tr>
		</c:forEach>
		
		<form id="f1" method="post">
		<input type="hidden" name="_method" value="DELETE">
		</form>
	</table>
</body>
</html>